(function($) {
	$.fn.extend({
		getFormParams : function(formJQueryFind) {
			var parameter = {};
			var trueValue = "";
			var trueKey = "";
			$(formJQueryFind).each(
					function() {
						for (var i = 0; i < this.length; i++) {
							var f = this[i];
							var key = f.name;
							if (key != null && key != '') {
								if ($(f).hasClass("easyui-combobox")
										|| $(f).hasClass("combo-text")
										|| $(f).hasClass("combo-value")) {
								} else {
								}
								if (key == trueKey) {
									trueValue += ",";
									trueValue += f.value;
								} else {
									trueValue = f.value;
								}
								if (trueValue == "") {
									trueValue = null;
								}
								parameter[key] = trueValue;
							}
							trueKey = key;
						}

					});
			return parameter;
		},
		messageInfoTip : function(data) {
			var obj = eval('(' + data + ')');
			console.log(JSON.stringify(data));
			var title = "系统提示",message;
			if (obj.status == 1) {
				title = "温馨提示";
				message = obj.errorMsg;
			}else{
				title = "系统警告";
				message = obj.errorMsg;
			}
			$.messager.show({
				title : title,
				msg : message,
				timeout : 5000,
				showType : 'slide'
			});
			return obj.status;
		},
		ajaxLoading :function(msg){
			if(!msg){
				msg = "正在处理，请稍候。。。";
			}
			$("<div class=\"datagrid-mask\"></div>").css({
				display : "block",
				width : "100%",
				height : $(window).height()
			}).appendTo("body");
			$("<div class=\"datagrid-mask-msg\"></div>").html(msg).css({
				display : "block",
				left : ($(document.body).outerWidth(true) - 190) / 2,
				top : ($(window).height() - 45) / 2
			}).appendTo("body");
		},
		ajaxLoaded:function(){
			$(".datagrid-mask").remove();   
			$(".datagrid-mask-msg").remove();               

		}
	}
	)
})(jQuery);

var LocString = String(window.document.location.href);
function getQueryStr(str) {
	var rs = new RegExp("(^|)" + str + "=([^&]*)(&|$)", "gi").exec(LocString), tmp;
	if (tmp = rs) {
	return tmp[2];
	}
	// parameter cannot be found
	return "";
}
//解析easyUI dataGrid的数据
function parseDataGrid(oldData){
	var retData={};
	if(oldData.status == 1){
		retData.total=oldData.data.total;
		retData.rows=oldData.data.rows;
	}else{
		retData.total=0;
		retData.rows=[];
	}
	return retData;
}

//加载下拉框数据
function setComboboxData(id,url){
	$.ajax({
		type:"POST",
		dataType:'html',
		url:url,
		success:function(oldData){
			var obj = eval('('+ oldData+ ')');
			if (obj.status == 1) {
				$(id).combobox("loadData",obj.data);
			}
		},
		error:function(textStatus){
			if(console){
				console.error("ajax出现异常:"+textStatus);
			}
			alert(textStatus);
		}
	});
}

//加载下拉框数据
function setCombotreeData(id,url){
	$.ajax({
		type:"POST",
		dataType:'html',
		url:url,
		success:function(oldData){
			var obj = eval('('+ oldData+ ')');
			if (obj.status == 1) {
				$(id).combotree("loadData",obj.data);
			}
		},
		error:function(textStatus){
			if(console){
				console.error("ajax出现异常:"+textStatus);
			}
			alert(textStatus);
		}
	});
}
